From: Keir Fraser Date: Thu, 24 Apr 2008 08:59:57 +0000 (+0100) Subject: xenbaked: Fix access to trace buffer after xentrace changes X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14215^2~127 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22man:///%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22man:/?a=commitdiff_plain;h=f3814331c731f6dc453d14c6373bfae109215606;p=xen.git xenbaked: Fix access to trace buffer after xentrace changes Signed-off-by: Naoki Nishiguchi --- diff --git a/tools/xenmon/xenbaked.c b/tools/xenmon/xenbaked.c index 32ca9f36c3..35ba8e40e9 100644 --- a/tools/xenmon/xenbaked.c +++ b/tools/xenmon/xenbaked.c @@ -509,14 +509,36 @@ int monitor_tbufs(void) { for ( i = 0; (i < num) && !interrupted; i++ ) { - while ( meta[i]->cons != meta[i]->prod ) + unsigned long start_offset, end_offset, cons, prod; + + cons = meta[i]->cons; + prod = meta[i]->prod; + xen_rmb(); /* read prod, then read item. */ + + if ( cons == prod ) + continue; + + start_offset = cons % data_size; + end_offset = prod % data_size; + + if ( start_offset >= end_offset ) + { + while ( start_offset != data_size ) + { + rec_size = process_record( + i, (struct t_rec *)(data[i] + start_offset)); + start_offset += rec_size; + } + start_offset = 0; + } + while ( start_offset != end_offset ) { - xen_rmb(); /* read prod, then read item. */ rec_size = process_record( - i, (struct t_rec *)(data[i] + meta[i]->cons % data_size)); - xen_mb(); /* read item, then update cons. */ - meta[i]->cons += rec_size; + i, (struct t_rec *)(data[i] + start_offset)); + start_offset += rec_size; } + xen_mb(); /* read item, then update cons. */ + meta[i]->cons = prod; } wait_for_event();